<extend name="Public/base"/>

<!-- 子导航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>

<block name="body">
	
	 	<div>
       
	<!-- 标题 -->
	<div class="main-title">
		<h2>
		商品列表({$_total}) [
		<volist name="rightNav" id="nav">
		<a href="{:U('article/index','cate_id='.$nav['id'])}">{$nav.title}</a>
			<if condition="count($rightNav) gt $i"><i class="ca"></i></if>
		</volist>
		<present name="article">：<a href="{:U('article/index','cate_id='.$cate_id.'&pid='.$article['id'])}">{$article.title}</a></present>
		]
		<eq name="allow" value="0">（该分类不允许发布内容）</eq>
		</h2>
	</div>

	<!-- 按钮工具栏 -->
	<div class="cf">
		<div class="fl">
			<!-- <div class="btn-group">
				<gt name="allow" value="0">
					<button class="btn document_add" <if condition="count($model) eq 1">url="{:U('article/add',array('cate_id'=>$cate_id,'pid'=>I('pid',0),'model_id'=>$model[0]))}"</if>>新 增
						<if condition="count($model) gt 1"><i class="btn-arrowdown"></i></if>
					</button>
					<if condition="count($model) gt 1">
					<ul class="dropdown nav-list">
						<volist name="model" id="vo">
						<li><a href="{:U('article/add',array('cate_id'=>$cate_id,'model_id'=>$vo,'pid'=>I('pid',0)))}">{$vo|get_document_model='title'}</a></li>
						</volist>
					</ul>
					</if>
				<else/>
					<button class="btn disabled" >新 增
						<if condition="count($model) gt 1"><i class="btn-arrowdown"></i></if>
					</button>
				</gt>
			</div> -->
<!-- 		<button class="btn ajax-post" target-form="ids" url="{:U("goodsadd",array("status"=>1))}">a新增</button>	
 -->		<a class="btn" href='{:U("goodsitem",array("status"=>1))}'>新 增</a>		
            <!--
            <button class="btn ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>1))}">鍚� 鐢�</button>
                        <button class="btn ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>0))}">绂� 鐢�</button>
                        <button class="btn ajax-post" target-form="ids" url="{:U("Article/move")}">绉� 鍔�</button>
                        <button class="btn ajax-post" target-form="ids" url="{:U("Article/copy")}">澶� 鍒�</button>
                        <button class="btn ajax-post" target-form="ids" hide-data="true" url="{:U("Article/paste")}">绮� 璐�</button>
                        <input type="hidden" class="hide-data" name="cate_id" value="{$cate_id}"/>
                        <input type="hidden" class="hide-data" name="pid" value="{$pid}"/>-->
            
			<button class="btn ajax-post confirm" target-form="ids" url="{:U("Article/setStatus",array("status"=>-1))}">下架</button>
			<!-- <button class="btn document_add" url="{:U('article/batchOperate',array('cate_id'=>$cate_id,'pid'=>I('pid',0)))}">导入</button> -->
			<button class="btn list_sort" url="{:U('sort',array('cate_id'=>$cate_id,'pid'=>I('pid',0)),'')}">排序</button>
		</div>

		
	<!-- 数据表格 -->
    <div class="data-table">
    <!--
        <?php 
              var_dump($list);
               var_dump($rulelist);
               ?>-->
    
		<table>
            <!-- 表头 -->
            
          <thead>
         
          
        
                <tr>
                    <th class="row-selected row-selected">
                        <input type="checkbox" class="check-all">
                    </th>
                    <th>编号</th>
                    <th>商品图片</th>
                    <th>标题</th>
                    <th>类别</th>
                    <th>商家</th>                   
                    <th>描述</th>
                    <th>介绍</th>
                    <th>浏览量</th>
                    <th>总销售量</th>
                    <th>属性</th>
                    
                   
                    <th>操作</th>                </tr>
            </thead>

            <!-- 列表 -->
            <tbody>
          
                  <volist name="list" id="data">
                  <tr>
                        <td><input type="checkbox" name="ids[]" value="237" class="ids"></td>
                         
                        <td>237</td>
                        <td>图片</td>
                        <td><a href="/admin.php?s=/Goods/edit/id/237/model/1/cate_id/44.html">{$data.good_name}</a></td>
                        <td>{$data.cat_name}</td>
                        <td>{$data.shopname}</td>
                        <td>{$data.good_remark}</td>
                        <td>{$data.good_brief||substr=0,15}...</td>
                        <td>{$data.click_con}</td>
                        <td>{$data.historysum}</td>
                        <if condition="($data.feature eq 1) ">  <td>热销</td>
						 <elseif condition="($data.feature eq 2) "/><td>新品</td>
						 <elseif condition="($data.feature eq 3) "/><td>推荐</td>
						 <else /> <td>普通商品</td>
						 </if>
                       
                    
                        <td>
                        <a href="{:U('goodsedit',array('good_id'=>$data['id']))}">编辑</a> <a href="/admin.php?s=/Goods/setstatus/status/-1/ids/237.html">下架</a>
                        </td>                  
                  </tr>
                  <volist name="rulelist" id="ruledata">
                  	<if condition="$ruledata['good_id'] eq $data['id'] ">  
                     <tr style="font: italic;font-size: 13px;font-style: oblique;">
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>规格：{$ruledata.rule_name}</td>
                        <td>价格：{$ruledata.rule_price}(元)</td>
                        <td>库存：{$ruledata.stock}(份)</td>
                        <td>重量：{$ruledata.weight}(斤)</td>
                        <td></td>
                        <td colspan ="2"></td>
                        <td></td>   
                        </if>               
                  </volist>
                  
                  </volist>
              
                <!-- <volist name="list" id="data">
                    <tr>
                        <td><input class="ids" type="checkbox" value="{$data['id']}" name="ids[]"></td>
                        <volist name="list_grids" id="grid">
                            <td>{:get_list_field($data,$grid,$model_list)}</td>
                        </volist>
                    </tr>
                </volist> -->
            </tbody>
        </table>
	</div>
	<!-- 分页 -->
    <div class="page">
        {$_page}
    </div>
</div>

</block>
<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
		var status = $("#sch-sort-txt").attr("data");
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
		if(status != ''){
			query += 'status=' + status + "&" + query;
        }
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

	/* 状态搜索子菜单 */
	$(".search-form").find(".drop-down").hover(function(){
		$("#sub-sch-menu").removeClass("hidden");
	},function(){
		$("#sub-sch-menu").addClass("hidden");
	});
	$("#sub-sch-menu li").find("a").each(function(){
		$(this).click(function(){
			var text = $(this).text();
			$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
			$("#sub-sch-menu").addClass("hidden");
		})
	});

	//只有一个模型时，点击新增
	$('.document_add').click(function(){
		var url = $(this).attr('url');
		if(url != undefined && url != ''){
			window.location.href = url;
		}
	});

	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

    $('#time-start').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });

    $('#time-end').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });
})
</script>
</block>
